<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="layui/css/layui.css" rel="stylesheet">
    <script src="layui/layui.js"></script>
    <script src="layuimini/js/lay-config.js"></script>
</head>
<body>

<form id="addUserDemo" lay-filter="addUserDemo"
      class="layui-form layui-form-pane"
      style="margin: 30px auto; display: inline-block;" >
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">席位名称</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="席位名称" class="layui-input" name="seatName">
        </div>
        <label class="layui-form-label layui-bg-gray" style=" width: 140px;margin-left: 50px;">席位类型</label>
        <div class="layui-input-inline">
            <select id="seatType" name="seatType">
                <option value="0">选择</option>
                <option value="1">普通席位</option>
                <option value="2">SVIP席位</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">佣金利率</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="佣金利率" class="layui-input" name="commission">
        </div>
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">券商ID</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="券商ID" class="layui-input" name="brokerId" id="brokerId">
            <input type="hidden" name="securityIdHidden" id="securityIdHidden">
        </div>
    </div>
    <div class="layui-form-item" style="text-align: center;">
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">券商名称</label>
        <div class="layui-input-inline">
            <input type="text" lay-verify="required"
                   autocomplete="off" placeholder="券商名称" class="layui-input" name="brokerName" id="brokerName">
        </div>
        <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">席位地址</label>
        <div class="layui-input-inline">
            <select id="seatPlace" name="seatPlace">
                <option value="0">选择</option>
                <option value="1">深圳席位</option>
                <option value="2">上海席位</option>
            </select>
        </div>
    </div>
    <label class="layui-form-label layui-bg-gray" style="width: 140px; margin-left: 35px">券商备注</label>
    <div class="layui-input-inline">
        <input type="text" lay-verify="required"
               autocomplete="off" placeholder="券商备注" class="layui-input" name="brokerRemark">
    </div>
    <div class="layui-form-item" style="position: absolute;left: 20%; bottom: 20px">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="addUser"><i class="layui-icon">&#x1005;</i>添加</button>
            <button type="reset" class="layui-btn layui-btn-primary"> <i class="layui-icon">&#x1006;</i>取消</button>
        </div>
    </div>

</form>

<script type="text/javascript">
    layui.use(['table', 'form', 'tableSelect'],function (){
        var form = layui.form;
        var $ = layui.jquery;
        tableSelect = layui.tableSelect;

        form.on('submit(addUser)',function(obj){
            console.log(obj.field);
            $.ajax({
                url:"insertDealSeatDealSeat",
                type:"get",
                data:obj.field,
                dataType:"text",
                contentType:"application/x-www-form-urlencoded",//内容类型  form 表单的
                success:function(msg){
                    if(msg==="ok"){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //新增托管人下拉表格
        tableSelect.render({
            elem: '#brokerId',
            checkedKey: 'brokerId',
            table: {
                url: '/selectDealSeatMap',
                cols: [
                    [
                        {type: 'radio', fixed: 'left'},
                        , {field: 'brokerId', title: '券商ID'}
                        , {field: 'brokerName', title: '券商名称'}
                        , {field: 'brokerRemark', title: '券商备注'}
                    ]]
            },
            done: function (elem, data) {
                var NEWJSON = [];
                layui.each(data.data, function (index, item) {
                    NEWJSON.push(item.brokerId)
                    $("#securityIdHidden").val(item.brokerId)
                    $("#brokerName").val(item.brokerName)
                });
                elem.val(NEWJSON.join(","))
            }
        });

    })
</script>
<script></script>
</body>
</html>